#pragma once
#include "Core.h"
#include "Events/Event.h"
#include "Platform/Windows/WinWindow.h"
#include "Events/ApplicationEvent.h"
#include "Events/KeyEvent.h"
#include "LayerStack.h"
#include "FysicsEngine/Imgui/ImguiLayer.h"
#include "Scene/Scene.h"

#include "FysicsEngine/Renderer/Buffer.h"
#include "FysicsEngine/Renderer/Shader.h"
#include "FysicsEngine/Renderer/VertexArray.h"
#include "FysicsEngine/Renderer/Renderer.h"

#include "TimeStep.h"

#define VA_BOX 0
#define VA_BOX_LIGHT 1
#define VA_CAMERA 2
#define VA_PLANE 3

#define SHADER_RED 0
#define SHADER_BLUE 1
#define SHADER_LIGHT 2
#define SHADER_LIGHTOBJ 3

namespace Fysics
{
	class FYSICS_API Application
	{
	public:
		Application();
		virtual ~Application();
		
		void Run();

		void OnEvent(Event& e);
		
		void PushLayer(Layer* layer);
		void PushOverlay(Layer* layer);

		static inline Application& Get() { return *s_Instance; }
		inline Window& GetWindow() { return *m_Window; }

		std::shared_ptr<Shader> GetShader(int i) const { return m_Shaders[i]; }
		std::shared_ptr<VertexArray> GetVertexArray(int i) const { return m_VertexArrays[i]; }
	private:
		bool OnWindowClose(WindowCloseEvent& e);
		bool OnWindowResize(WindowResizeEvent& e);
		bool OnKeyPressed(KeyPressedEvent& e);

		std::unique_ptr<Window> m_Window;
		bool m_Running = true;
		LayerStack m_LayerStack;
		ImguiLayer* m_ImguiLayer;

		Scene* m_Scene;
		float m_LastFrameTime = 0.0f;

		std::vector<std::shared_ptr<VertexArray>> m_VertexArrays;
		std::vector<std::shared_ptr<Shader>> m_Shaders;
	private:
		static Application* s_Instance;
	};

	Application* CreateApplication();
}
